package collection;

import java.util.ArrayList;
import java.util.List;

public class SortPoint {
    public static void main(String[] args) {
        List<Point> list = new ArrayList<>();
        list.add(new Point(1,2));
        list.add(new Point(321,423));
        list.add(new Point(5,63));
        list.add(new Point(7213,81));
        list.add(new Point(933,102));
        System.out.println("list原始数据:  "+list);

        list.sort((p1,p2)->{
            int len1 = p1.getX()*p1.getX()+p1.getY()*p1.getY();
            int len2 = p2.getX()*p2.getX()+p2.getY()*p2.getY();
            return len1-len2;
        });
        System.out.println("list排序后数据:  "+list);
    }
}
